/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    bool isPalindrome(ListNode* head) {
        vector<int> ret1;
        ListNode* temp=head;
        while(temp) {
            ret1.push_back(temp->val);
            temp=temp->next;
        }
        for(int i=0;i<ret1.size();++i){
            if(ret1[i] != ret1[ret1.size()-1-i]) 
                return false;
        }
        return true;
    }
};